
#include <stdio.h>


#include <cv.h>
#include <highgui.h>
#include <ml.h>
#include "resourceTracker.h"

/*
 *  GestureClassifier_scrap.cpp
 *  
 *
 *  Created by Rasmus Kyng on 11/01/2011.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */


//class GestureClassifier {
//public:
//	train( CvDTreeTrainData*
//
//}

using namespace cv;

int main() {
	
	CvBoost* boostClassifier = new CvBoost();
	
	ResourceTracker* rt = new ResourceTracker( "../config/runtimeSettings/cfg.xml" );
	rt->loadCategory("TestData");
	
	cv::Ptr< cv::VideoCapture > capPtr;
	cv::Ptr< VideoPointTagSequence > seqPtr;
	
	char* videoNameString = "locVid1c";
	
	capPtr = rt->getFileVideoCapture( videoNameString );
	seqPtr = rt->getPointTags( videoNameString );
	
	int handRectSideLength = 100;
	
	Rect handRect = Rect( 0, 0, handRectSideLength, handRectSideLength);
	
	int tagCount = seqPtr->tagCount;
	
	// -- Visualisation -- //
	namedWindow( "classifierScrap", 1 );
	Mat frame;
	for( int frameCount = 0; frameCount<tagCount; frameCount++) {
		
		(*capPtr) >> frame;
		
		// -- tracking frame -- //
		Point groundTruth = seqPtr->getNextPointTag();
		handRect = Rect( groundTruth.x - handRect.width/2, groundTruth.y - handRect.height/2, handRect.width, handRect.height );
		
		{
			rectangle( frame, Point(handRect.x, handRect.y),
					  Point(handRect.x + handRect.width, handRect.y + handRect.height),
					  Scalar::all(250));
			
			circle( frame, groundTruth, 1, Scalar(0, 255, 0), 2 ); //radius 1, thickness 2, colour green
			//NOTE: BGR colour!
			
			imshow( "classifierScrap", frame );
		}
		
		// -- get next frame -- //
		
		waitKey(1);
	}

	
	delete rt;
	delete boostClassifier;

	return 0;

}